package cn.itcast.order.web.ijpay.ijpayconfig;

import com.ijpay.alipay.AliPayApiConfigKit;
import com.ijpay.wxpay.WxPayApiConfig;
import com.ijpay.wxpay.WxPayApiConfigKit;

/**
 * @author sxt
 * @version 1.0
 * @description wxpay 支付api配置
 * @date 2024/4/26 18:09
 */
public abstract class AbsWxPayApiConfig implements IJPayApiConfig<WxPayApiConfig> {
    @Override
    public void setApiConfig(WxPayApiConfig config) {
        WxPayApiConfigKit.putApiConfig(config);
    }

    @Override
    public void setThreadLocalApiConfigConfig(WxPayApiConfig config) {
        WxPayApiConfigKit.setThreadLocalWxPayApiConfig(config);
    }

    @Override
    public void setThreadLocalApiConfigConfig() {
        WxPayApiConfigKit.setThreadLocalWxPayApiConfig(getDefaultApiConfig());
    }

    @Override
    public void removeApiConfig(Object configId) {
        WxPayApiConfigKit.removeApiConfig(configId.toString());
    }

    @Override
    public void removeThreadLocalApiConfig() {
        WxPayApiConfigKit.removeThreadLocalAppId();
    }

    @Override
    public WxPayApiConfig getApiConfig(Object configId) {
        try {
            return WxPayApiConfigKit.getApiConfig(configId.toString());
        } catch (Exception e) {
            return null;
        }
    }
}
